#ifndef Command_h__
#define Command_h__

#include <sstream>
#include <string>
#include <vector>
#include <functional>

using std::stringstream;
using std::string;
using std::vector;
using std::function;

class Parameter {
private:
	stringstream mString;
public:
	Parameter() : mString("") {

	}

	Parameter(string input) : mString(input) {
	
	}

	Parameter(const Parameter& former) {
		mString.str(former.mString.str());
	}

	template<typename T> bool to(T& out) {
		mString.seekg(0, std::ios::beg);
		mString.clear();
		mString >> out;
		return mString.good();
	}

	template<typename T> T toOrElse(T e) {
		T c;
		if (to(c)) {
			return c;
		} else {
			return e;
		}
	}
};

typedef function<string(vector<Parameter>&)> CommandFunction;

class Command {
private:
	CommandFunction& mFunction;
	vector<Parameter> mParameters;
public:
	Command(CommandFunction&, vector<Parameter>);
	string run();
};

#endif // Command_h__